#pragma once

#include <atlcomcli.h>
#include <memory>
#include "AdpcmSourceFilter.h"

using namespace std;

__interface IGraphBuilder;

class AdpcmPlayer
{
public:
	AdpcmPlayer(int channels, int sampleRate, int bitsPerSample, AudioCodecId codecId);
	virtual ~AdpcmPlayer(void);

	int PlaybackAudioData(char *data, int len);
	int SetVolume(int volume);
	int GetVolume();

	bool IsInitialized() { return m_isInitialized;}

	bool StartPlay();
	void StopPlay();

private:
	AdpcmPlayer(void) {}

	bool m_isInitialized;
	int m_channels;
	int m_sampleRate;
	int m_bitsPerSample;
	AudioCodecId m_codecId;
	auto_ptr< CPushSourceAdpcmAudio > m_sourceFilter;
	CComQIPtr< IGraphBuilder > m_filterGraph;

	int InitPlayer();
	int DestroyPlayer();
};
